Add support for DHCP hostname#921
Closed
Channel59 wants to merge 5 commits intoarduino:mainfrom
Closed
Conversation
Contributor
Author
|
The compiler errors arise from the fact that a call to Ethernet.begin(nullptr) is ambiguous now: /home/runner/work/ArduinoCore-mbed/ArduinoCore-mbed/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino:143:29: error: call of overloaded 'begin(std::nullptr_t)' is ambiguous
if (Ethernet.begin(nullptr) == 0) {
^
In file included from /home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/PortentaEthernet.h:3:0,
from /home/runner/work/ArduinoCore-mbed/ArduinoCore-mbed/libraries/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino:22:
/home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/Ethernet.h:65:7: note: candidate: int arduino::EthernetClass::begin(uint8_t*, long unsigned int, long unsigned int)
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
^~~~~
/home/runner/.arduino15/packages/arduino/hardware/mbed/3.3.0/libraries/Ethernet/src/Ethernet.h:66:7: note: candidate: int arduino::EthernetClass::begin(const char*)
int begin(const char* hostname);
^~~~~I suppose to make sure no code is broken the If someone has a more elegant solution please let me know. |
…t char* hostname) method.
Contributor
|
Hi @Channel59 thank you so much for your contribution! |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recently someone pointed me to this PR on the mbed-os repo: ARMmbed/mbed-os#15506.
The patches to make these changes are included in this pull request and so the credits for these patches full go to https://github.com/guilhermerc.
It enables the use of a hostname when DHCP is used to obtain an IP address.
Subsequently, the Ethernet.cpp and Ethernet.h are adjusted to allow the hostname to be set:
Either usingEthernet.begin("desired-hostname");or using a somewhat more Arduino-like api:
Ethernet.setHostname("desired-hostname"); Ethernet.begin();Before this compiles,
libmbed.ashould be recompiled on https://github.com/ARMmbed/mbed-os/tree/latest which will also patch some of the header files that are required to compile the arduino program.The code seems to work correctly with the opta. Any testing / refinements are more than welcome.
I do not have a wifi enabled device, so I cannot test it, but with these patches applied, a small change to Wifi.h and Wifi.cpp could add support for Wifi as well.